package cn.xyfmzmy.adapter.spring.etcd;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

/**
 * 用于替换RedisTemplate的适配器，注册到spring容器中替换RedisTemplate
 * 这里泛型设置成String类型
 */
public class EtcdRedisTemplateAdapter extends RedisTemplate<String,String> {

    private final EtcdValueOperations operations;

    public EtcdRedisTemplateAdapter(EtcdValueOperations operations) {
        this.operations = operations;
    }


    // 重写opsForValue方法，底层替换为Etcd的实现，返回自定义的EtcdValueOperations
    @Override
    public ValueOperations<String, String> opsForValue() {
        return operations;
    }

    // 重写initializeBean里定义生命周期函数，改成什么都不做，跳过redis注册检查
    @Override
    public void afterPropertiesSet() {

    }
}
